
import { _decorator, Component, Node } from 'cc';
import Action3dManager, { Action3d, ActionMngType } from '../../Script/Common/Action3dManager';
import EventManager from '../../Script/Common/EventManager';
import { EventType } from '../../Script/GameSpecial/GameEventType';
const { ccclass, property } = _decorator;

@ccclass('BtnNativeAd')
export class BtnNativeAd extends Component {

    onLoad() {
        this.initAction();
    }

    onClick() {
        EventManager.emit(EventType.Common.HeyGameSDK.clickNativeAd);
    }

    protected action: Action3d = null;
    protected initAction() {
        let s = this.node.scale.x - 0.05;
        let d = 1;
        let scale0 = Action3dManager.scaleTo(d, s, s, s);
        s += 0.1;
        let scale1 = Action3dManager.scaleTo(d, s, s, s);
        let seq = Action3dManager.sequence(scale0, scale1);
        this.action = Action3dManager.repeatForever(seq);
    }
    onEnable() {
        Action3dManager.getMng(ActionMngType.UI).runAction(this.node, this.action);
    }
    onDisable() {
        Action3dManager.getMng(ActionMngType.UI).stopAllActions(this.node);
    }

}
